(function(){"use strict";BX.namespace("BX.Landing.UI.Button");BX.Landing.UI.Button.FontAction=function(t,n){BX.Landing.UI.Button.EditorAction.apply(this,arguments);this.layout.classList.add("landing-ui-button-editor-action-font");this.content=BX.create("div",{props:{className:"landing-ui-button-editor-action-font-popup-content"}});this.fontSize=new BX.Landing.UI.Field.Range({title:BX.Landing.Loc.getMessage("EDITOR_ACTION_FIELD_LABEL_FONT_SIZE"),items:Array.apply(null,{length:160}).map((function(t,n){return{value:n,name:n}})),jsDD:top.window.jsDD,property:"font-size",onDragStart:this.onDragStart.bind(this),onDragEnd:this.onDragEnd.bind(this),onChange:this.onChange.bind(this)});BX.Landing.UI.Button.FontAction.instances.push(this)};BX.Landing.UI.Button.FontAction.instances=[];BX.Landing.UI.Button.FontAction.hideAll=function(){BX.Landing.UI.Button.FontAction.instances.forEach((function(t){if(t.popup){t.popup.close()}}))};BX.Landing.UI.Button.FontAction.prototype={constructor:BX.Landing.UI.Button.FontAction,__proto__:BX.Landing.UI.Button.EditorAction.prototype,onDragStart:function(){this.popup.popupContainer.classList.add("landing-ui-fade")},onDragEnd:function(){this.popup.popupContainer.classList.remove("landing-ui-fade")},onChange:function(t,n,o,i){if(i==="font-size"){var e=this.contextDocument.defaultView.getSelection();var a=e.getRangeAt(0);var p=BX.Landing.UI.Panel.EditorPanel.getInstance().currentElement.contains(a.startContainer);if(e.toString()&&p){this.contextDocument.execCommand("fontSize",false,t);a=this.contextDocument.defaultView.getSelection().getRangeAt(0);var s=a.startContainer.parentNode;s.style.fontSize=t+"px"}}},onClick:function(t){t.preventDefault();t.stopPropagation();if(!this.popup){this.popup=this.createPopup();this.popup.popupContainer.addEventListener("click",this.onPopupClick.bind(this));this.popup.popupContainer.classList.add("landing-ui-button-editor-action-font-popup");this.popup.contentContainer.appendChild(this.content);this.content.appendChild(this.fontSize.layout)}if(!this.popup.isShown()){this.popup.show();var n=BX.Landing.UI.Panel.EditorPanel.getInstance().isFixed()?"fixed":"relative";this.adjustPosition(n);BX.Landing.UI.Button.ColorAction.hideAll();var o=this.contextDocument.defaultView.getSelection();var i=o.getRangeAt(0);var e=BX.Landing.UI.Panel.EditorPanel.getInstance().currentElement.contains(i.startContainer);if(e){var a=i.startContainer.parentNode;var p=parseInt(getComputedStyle(a).getPropertyValue("font-size"));this.fontSize.setValue(p,true)}}else{this.popup.close()}},onPopupClick:function(t){t.stopPropagation()},adjustPosition:function(t){BX.DOM.read(function(){var n=this.popup.popupContainer.getBoundingClientRect();var o=this.layout.parentNode.getBoundingClientRect();var i=Math.abs(n.width-o.width);var e={};e["left"]=o.left+i/2+"px";if(t==="fixed"){var a=this.layout.getBoundingClientRect();e["top"]=a.bottom+"px";e["position"]="fixed"}else{var p=BX.pos(this.layout);e["top"]=p.bottom+"px"}BX.DOM.write(function(){for(var t in e){this.popup.popupContainer.style[t]=e[t]}}.bind(this))}.bind(this))},createPopup:function(){return new BX.PopupWindow("landing_font_editor_popup",this.layout,{autoHide:true,closeByEsc:true,noAllPaddings:true,width:463,zIndex:-979})}}})();
//# sourceMappingURL=font_action.map.js